package com.lotter.controller;


import java.io.IOException;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lotter.common.enumobject.RandomTypeEunm;
import com.lotter.common.util.CaptchaUtil;
import com.lotter.dal.BaseController;



/**
 * @ClassName: SecurityController 
 * @Description: 鍥惧舰楠岃瘉鐮�
 * @author zhangzechi
 * @date 2016骞�7鏈�27鏃� 涓婂崍11:29:33  
 * @version V1.0
 */
@Controller
public class SecurityController extends BaseController {
	
	@ResponseBody
	@RequestMapping(value="/captcha",method=RequestMethod.GET)
	public void captcha(HttpServletRequest request,HttpServletResponse response) throws IOException{
		response.setDateHeader("Expires", 0);
        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
        response.setHeader("Pragma", "no-cache");
        response.setContentType("image/jpeg");
        String captchaCode = CaptchaUtil.generateVerifyCode(4,RandomTypeEunm.ALL.getCode());
        //SessionUtil.setCaptcha(request, captchaCode);
        ServletOutputStream out = response.getOutputStream();
        CaptchaUtil.outputImage(100, 40, out, captchaCode);
        try {
            out.flush();
        } finally {
            out.close();
        }
	}

}
